package com.yingsheng.bi.hks.web.controller;

import com.yingsheng.bi.hks.dto.goods.*;
import com.yingsheng.bi.hks.feign.client.GoodsFeignClient;
import com.yingsheng.bi.hks.service.goods.GoodsMgmtService;
import com.yingsheng.bi.hks.service.goods.GoodsPayBiService;
import com.yingsheng.bi.hks.template.annotation.Template;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.RestController;

/**
 * 商品管理
 *
 * @author 83686
 */
@RestController
public class GoodsCtrl implements GoodsFeignClient {

    @Autowired
    private GoodsMgmtService goodsMgmtService;

    @Autowired
    private GoodsPayBiService goodsPayBiService;

    @Template(name = "accessTransTemplate")
    @Override
    public GoodsAddRes add(@Validated GoodsAddReq req) {
        return goodsMgmtService.add(req);
    }

    @Template(name = "accessTransTemplate")
    @Override
    public GoodsSpecAddRes goodsSpecAdd(@Validated GoodsSpecAddReq req) {
        return goodsMgmtService.goodsSpecAdd(req);
    }

    @Template(name = "publicQueryTemplate")
    @Override
    public GoodsSpecQryRes goodsSpecQry(@Validated GoodsSpecQryReq req) {
        return goodsMgmtService.goodsSpecQry(req);
    }

    @Template(name = "publicQueryTemplate")
    @Override
    public GoodsQryRes goodsQry(@Validated GoodsQryReq req) {
        return goodsMgmtService.goodsQry(req);
    }

    @Template(name = "publicQueryTemplate")
    @Override
    public GoodsDetailQryRes goodsDetailQry(@Validated GoodsDetailQryReq req) {
        return goodsMgmtService.goodsDetailQry(req);
    }

    @Template(name = "accessTransTemplate")
    @Override
    public GoodsBuyRes goodsOrderQry(@Validated GoodsBuyReq req) {
        return goodsPayBiService.process(req);
    }

    @Template(name = "accessQueryTemplate")
    @Override
    public GoodsOrderQryRes goodsOrderQry(@Validated GoodsOrderQryReq req) {
        return goodsMgmtService.goodsOrderQry(req);
    }
}
